#!/usr/bin/env python
# coding: utf-8

# In[2]:


import requests,json
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=c0EEdYVyO34qiUxP7UdjYCrE&client_secret=u7LqtuyouoYwb5RZ20rBELykCe2qljAn'
response = requests.get(host)
# if response:
#     print(response.json())
    
appid = '23388575'


# In[3]:

# 皮肤检测
def skin_test(image):
    """皮肤检测"""
    request_url = "https://aip.baidubce.com/rest/2.0/face/v1/skin_analyze"
    params = {
    "appid":"23388575",
    # "image": "https://vicky-newmedia.gitee.io/api_photo/image/linxixi.jpg",
    "image_type": "URL",
    "face_field": "color,smooth,acnespotmole,wrinkle,eyesattr,blackheadpore",
    "max_face_num": 10
}
    access_token = '24.535b1e4d22400ac3ee3cb8d976375a87.2592000.1611455181.282335-23388575'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/json'}
    response = requests.post(request_url, data=params, headers=headers)
    data = response.json()
    return data

# 人脸数量
def face_num(image):
    """皮肤检测"""
    request_url = "https://aip.baidubce.com/rest/2.0/face/v1/skin_analyze"
    params = {
    "appid":"23388575",
    # "image": "https://vicky-newmedia.gitee.io/api_photo/image/linxixi.jpg",
    "image_type": "URL",
    "face_field": "color,smooth,acnespotmole,wrinkle,eyesattr,blackheadpore",
    "max_face_num": 10
}
    access_token = '24.535b1e4d22400ac3ee3cb8d976375a87.2592000.1611455181.282335-23388575'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/json'}
    response = requests.post(request_url, data=params, headers=headers)
    data = response.json()
    num = data['result']['face_num']
    return num

# 痘痘数量
def dou_num(image):
    """皮肤检测"""
    request_url = "https://aip.baidubce.com/rest/2.0/face/v1/skin_analyze"
    params = {
    "appid":"23388575",
    # "image": "https://vicky-newmedia.gitee.io/api_photo/image/linxixi.jpg",
    "image_type": "URL",
    "face_field": "color,smooth,acnespotmole,wrinkle,eyesattr,blackheadpore",
    "max_face_num": 10
}
    access_token = '24.535b1e4d22400ac3ee3cb8d976375a87.2592000.1611455181.282335-23388575'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/json'}
    response = requests.post(request_url, data=params, headers=headers)
    data = response.json()
    num = data['result']['face_list'][0]['acnespotmole']['acne_num']
    return num

# 痣数量
def zhi_num(image):
    """皮肤检测"""
    request_url = "https://aip.baidubce.com/rest/2.0/face/v1/skin_analyze"
    params = {
    "appid":"23388575",
    # "image": "https://vicky-newmedia.gitee.io/api_photo/image/linxixi.jpg",
    "image_type": "URL",
    "face_field": "color,smooth,acnespotmole,wrinkle,eyesattr,blackheadpore",
    "max_face_num": 10
}
    access_token = '24.535b1e4d22400ac3ee3cb8d976375a87.2592000.1611455181.282335-23388575'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/json'}
    response = requests.post(request_url, data=params, headers=headers)
    data = response.json()
    num = data['result']['face_list'][0]['acnespotmole']['mole_num']
    return num

# 斑数量
def ban_num(image):
    """皮肤检测"""
    request_url = "https://aip.baidubce.com/rest/2.0/face/v1/skin_analyze"
    params = {
    "appid":"23388575",
    # "image": "https://vicky-newmedia.gitee.io/api_photo/image/linxixi.jpg",
    "image_type": "URL",
    "face_field": "color,smooth,acnespotmole,wrinkle,eyesattr,blackheadpore",
    "max_face_num": 10
}
    access_token = '24.535b1e4d22400ac3ee3cb8d976375a87.2592000.1611455181.282335-23388575'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/json'}
    response = requests.post(request_url, data=params, headers=headers)
    data = response.json()
    num = data['result']['face_list'][0]['acnespotmole']['speckle_num']
    return num

# 皱纹数量
def zhou_num(image):
    """皮肤检测"""
    request_url = "https://aip.baidubce.com/rest/2.0/face/v1/skin_analyze"
    params = {
    "appid":"23388575",
    # "image": "https://vicky-newmedia.gitee.io/api_photo/image/linxixi.jpg",
    "image_type": "URL",
    "face_field": "color,smooth,acnespotmole,wrinkle,eyesattr,blackheadpore",
    "max_face_num": 10
}
    access_token = '24.535b1e4d22400ac3ee3cb8d976375a87.2592000.1611455181.282335-23388575'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/json'}
    response = requests.post(request_url, data=params, headers=headers)
    data = response.json()
    num = data['result']['face_list'][0]['wrinkle']['wrinkle_num']
    return num


